local skel = fk.CreateSkill {
  name = "rmt__penga",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["rmt__penga"] = "嘭！",
  [":rmt__penga"] = "锁定技，你获得其他基本牌后弃置之，并获得双倍数量的<a href=':peng'>【嘭！】</a>。你的【嘭！】不计入手牌上限。",
}

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(skel.name) then return false end
    local ids = {}
    for _, move in ipairs(data) do
      if move.toArea == Player.Hand and move.to == player then
        for _, info in ipairs(move.moveInfo) do
          if table.contains(player.player_cards[Player.Hand], info.cardId) then
            Fk:filterCard(info.cardId, player)
            local c = Fk:getCardById(info.cardId)
            if c.type == Card.TypeBasic and c.name ~= "peng" then
              table.insertIfNeed(ids, info.cardId)
            end
          end
        end
      end
    end
    if #ids > 0 then
      event:setCostData(self, {cards = ids})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = table.simpleClone(event:getCostData(self).cards)
    room:throwCard(cards, skel.name, player, player)
    if player.dead then return end
    room:delay(100)
    local get = {}
    for _ = 1, #cards * 2 do
      table.insert(get, room:printCard("peng", math.random(4), 12).id)
    end
    room:obtainCard(player, get, true, fk.ReasonJustMove, player, skel.name)
  end,
})

-- 弃掉初始手牌的基本牌
skel:addEffect(fk.AfterDrawInitialCards, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(skel.name) or target ~= player then return false end
    local ids = table.filter(player.player_cards[Player.Hand], function (id)
      local c = Fk:getCardById(id)
      return c.type == Card.TypeBasic and c.name ~= "peng"
    end)
    if #ids > 0 then
      event:setCostData(self, {cards = ids})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = table.simpleClone(event:getCostData(self).cards)
    room:throwCard(cards, skel.name, player, player)
    if player.dead then return end
    room:delay(100)
    local get = {}
    for _ = 1, #cards * 2 do
      table.insert(get, room:printCard("peng", math.random(4), 12).id)
    end
    room:obtainCard(player, get, true, fk.ReasonJustMove, player, skel.name)
  end,
})

skel:addEffect("maxcards", {
  exclude_from = function(self, player, card)
    return card and card.trueName == "peng" and player:hasSkill(skel.name)
  end,
})

return skel
